public class SevenBinaryConversion {

    public static void main(String[] args) {
        String str = "103";
        // Api验证
        System.out.println(Integer.parseInt(str, 7));
        // 自己的代码结果
        System.out.println(seven(str));
    }

    public static int seven(String num) {
        int weight = 7;
        int size = 0;
        int sum = 0;
        for (int i = num.length() - 1; i >= 0; i--) {
            char t = num.charAt(i);
            // int numericValue = Character.getNumericValue(t);
            // 将字符转换成数字
            int numericValue = t - '0';
            sum += numericValue * Math.pow(weight, size);
            ++size;
        }
        return sum;
    }
}